#ifndef _EVENT_HPP
#define _EVENT_HPP

#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <string>
#include <memory>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <error.h>
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>

class Event;
class Reactor;
// 回调函数处理事件
typedef int (*epoll_callback_t)(Event* event);

class Event
{
public:
    // epoll事件
    struct epoll_event _event;

    // 缓冲区设置
    std::string _in_buffer;
    std::string _out_buffer;
  
    // 回调处理方法
    epoll_callback_t _recv;
    epoll_callback_t _send;
    epoll_callback_t _error;

    // 回指Reactor
    Reactor *_R;

    // 对应的fd
    int _sock;

    Event()
      :_recv(nullptr), _send(nullptr), _error(nullptr), _R(nullptr), _sock(-1)
    {}

    void RegisterCallback(epoll_callback_t recv, epoll_callback_t send, epoll_callback_t error)
    {
        _recv = recv;
        _send = send;
        _error = error;
    }
};

#endif
